package com.hsq.androidproject.ui;

import android.content.Intent;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.lenovo.androidproject3.R;
import com.hsq.androidproject.adapter.MyFragmentPagerAdapter;
import com.hsq.androidproject.entity.find.FindCates;
import com.hsq.androidproject.ui.find_fragment.EightFragment;
import com.hsq.androidproject.ui.find_fragment.ElevenFragment;
import com.hsq.androidproject.ui.find_fragment.FiveFragment;
import com.hsq.androidproject.ui.find_fragment.FourFragment;
import com.hsq.androidproject.ui.find_fragment.NineFragment;
import com.hsq.androidproject.ui.find_fragment.OneFragment;
import com.hsq.androidproject.ui.find_fragment.SevenFragment;
import com.hsq.androidproject.ui.find_fragment.SixFragment;
import com.hsq.androidproject.ui.find_fragment.TenFragment;
import com.hsq.androidproject.ui.find_fragment.ThreeFragment;
import com.hsq.androidproject.ui.find_fragment.TwoFragment;
import com.hsq.androidproject.utils.OkHttpClientManager;
import com.google.gson.Gson;
import com.squareup.okhttp.Request;

import java.util.ArrayList;
import java.util.List;

public class ShowFindEightActivity extends FragmentActivity {

    private String name;
    private int cid;
    private TextView tv_name;

    /**/
    private Fragment oneFragment, twoFragment, threeFragment, fourFragment, fiveFragment, sixFragment, sevenFragment, eightFragment, nineFragment, tenFragment, elevenFragment;
    private ViewPager mPager;
    private ArrayList<Fragment> fragmentList;
    private TextView view1, view2, view3, view4, view5, view6, view7, view8, view9, view10, view11;
    private int currIndex;//当前页卡编号

    private HorizontalScrollView mHorizontalScrollView;
    private int scrollViewWidth;
    private List<FindCates.CatesBean.ChildListBean> childListBeen;
    private FindCates.CatesBean catesBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_find_eight);
        Intent intent = getIntent();            /////MyGridViewFindAdapter传过来的数据
        name = intent.getStringExtra("name");
        cid = intent.getIntExtra("cid", 0);
        initView();
        initTextView();
        mHorizontalScrollView = (HorizontalScrollView) findViewById(R.id.mHorizontalScrollView);


        OkHttpClientManager.getAsyn("http://api.hanju.koudaibaobao.com/api/cate/cates", new OkHttpClientManager.ResultCallback<String>() {
            @Override
            public void onError(Request request, Exception e) {
                Toast.makeText(ShowFindEightActivity.this, "error：" + e.getMessage(), Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onResponse(String response) {
                FindCates findCates = new Gson().fromJson(response, FindCates.class);
                List<FindCates.CatesBean> cates = findCates.getCates();
                if (cid == 3) {                 ////美妆护肤
                    catesBean = cates.get(0);
                } else if (cid == 1) {          /////美食
                    catesBean = cates.get(1);
                } else if (cid == 4) {           ////减肥健身
                    catesBean = cates.get(2);
                } else if (cid == 10) {              ////娱乐
                    catesBean = cates.get(3);
                } else if (cid == 5) {             ////星座
                    catesBean = cates.get(4);
                } else if (cid == 2) {          //旅行
                    catesBean = cates.get(5);
                } else if (cid == 46) {          //////用户推荐",
                    catesBean = cates.get(6);
                }

                ///Toast.makeText(ShowFindEightActivity.this, "" + childListBeen.get(0).getPid() + "," + cid, Toast.LENGTH_SHORT).show();
                childListBeen = catesBean.getChildList();
                int count = childListBeen.size() + 1;
                if (count == 6) {            ////娱乐
                    Toast.makeText(ShowFindEightActivity.this, "" + count, Toast.LENGTH_SHORT).show();
                    view1.setText("推荐");
                    childListBeen = catesBean.getChildList();
                    view2.setText(childListBeen.get(0).getName());
                    view3.setText(childListBeen.get(1).getName());
                    view4.setText(childListBeen.get(2).getName());
                    view5.setText(childListBeen.get(3).getName());
                    view6.setText(childListBeen.get(4).getName());
                    view7.setVisibility(View.GONE);
                    view8.setVisibility(View.GONE);
                    view9.setVisibility(View.GONE);
                    view10.setVisibility(View.GONE);
                    view11.setVisibility(View.GONE);
                } else if (count == 8) {
                    view1.setText("推荐");
                    childListBeen = catesBean.getChildList();
                    view2.setText(childListBeen.get(0).getName());
                    view3.setText(childListBeen.get(1).getName());
                    view4.setText(childListBeen.get(2).getName());
                    view5.setText(childListBeen.get(3).getName());
                    view6.setText(childListBeen.get(4).getName());
                    view7.setText(childListBeen.get(5).getName());
                    view8.setText(childListBeen.get(6).getName());
                    view9.setVisibility(View.GONE);
                    view10.setVisibility(View.GONE);
                    view11.setVisibility(View.GONE);
                } else if (count == 3) {          //星座
                    view1.setText("推荐");
                    childListBeen = catesBean.getChildList();
                    view2.setText(childListBeen.get(0).getName());
                    view3.setText(childListBeen.get(1).getName());
                    view4.setVisibility(View.GONE);
                    view5.setVisibility(View.GONE);
                    view6.setVisibility(View.GONE);
                    view7.setVisibility(View.GONE);
                    view8.setVisibility(View.GONE);
                    view9.setVisibility(View.GONE);
                    view10.setVisibility(View.GONE);
                    view11.setVisibility(View.GONE);
                } else if (count == 7) {          //旅行
                    view1.setText("推荐");
                    childListBeen = catesBean.getChildList();
                    view2.setText(childListBeen.get(0).getName());
                    view3.setText(childListBeen.get(1).getName());
                    view4.setText(childListBeen.get(2).getName());
                    view5.setText(childListBeen.get(3).getName());
                    view6.setText(childListBeen.get(4).getName());
                    view7.setText(childListBeen.get(5).getName());
                    view8.setVisibility(View.GONE);
                    view9.setVisibility(View.GONE);
                    view10.setVisibility(View.GONE);
                    view11.setVisibility(View.GONE);
                } else if (count == 11) {          //用户推荐
                    view1.setText("推荐");
                    childListBeen = catesBean.getChildList();
                    view2.setText(childListBeen.get(0).getName());
                    view3.setText(childListBeen.get(1).getName());
                    view4.setText(childListBeen.get(2).getName());
                    view5.setText(childListBeen.get(3).getName());
                    view6.setText(childListBeen.get(4).getName());
                    view7.setText(childListBeen.get(5).getName());
                    view8.setText(childListBeen.get(6).getName());
                    view9.setText(childListBeen.get(7).getName());
                    view10.setText(childListBeen.get(8).getName());
                    view11.setText(childListBeen.get(9).getName());
                }

                InitViewPager();
            }
        });

        tv_name.setText(name + "           ");
    }

    Bundle bundle;
    int id;

    private void InitViewPager() {
        mPager = (ViewPager) findViewById(R.id.viewpager);
        int count = childListBeen.size() + 1;
        fragmentList = new ArrayList<>();

        if (count == 6) {            ////娱乐
            oneFragment = new OneFragment();            /////推荐
            bundle = new Bundle();
            bundle.putInt("cid", cid);
            oneFragment.setArguments(bundle);

            twoFragment = new TwoFragment();
            bundle = new Bundle();
            id = childListBeen.get(0).getId();
            bundle.putInt("cid", id);
            twoFragment.setArguments(bundle);

            threeFragment = new ThreeFragment();
            bundle = new Bundle();
            id = childListBeen.get(1).getId();
            bundle.putInt("cid", id);
            threeFragment.setArguments(bundle);

            fourFragment = new FourFragment();
            bundle = new Bundle();
            id = childListBeen.get(2).getId();
            bundle.putInt("cid", id);
            fourFragment.setArguments(bundle);

            fiveFragment = new FiveFragment();
            bundle = new Bundle();
            id = childListBeen.get(3).getId();
            bundle.putInt("cid", id);
            fiveFragment.setArguments(bundle);

            sixFragment = new SixFragment();
            bundle = new Bundle();
            id = childListBeen.get(4).getId();
            bundle.putInt("cid", id);
            sixFragment.setArguments(bundle);

            fragmentList.add(oneFragment);
            fragmentList.add(twoFragment);
            fragmentList.add(threeFragment);
            fragmentList.add(fourFragment);
            fragmentList.add(fiveFragment);
            fragmentList.add(sixFragment);
        } else if (count == 8) {
            oneFragment = new OneFragment();            /////推荐
            bundle = new Bundle();
            bundle.putInt("cid", cid);
            oneFragment.setArguments(bundle);

            twoFragment = new TwoFragment();
            bundle = new Bundle();
            id = childListBeen.get(0).getId();
            bundle.putInt("cid", id);
            twoFragment.setArguments(bundle);

            threeFragment = new ThreeFragment();
            bundle = new Bundle();
            id = childListBeen.get(1).getId();
            bundle.putInt("cid", id);
            threeFragment.setArguments(bundle);

            fourFragment = new FourFragment();
            bundle = new Bundle();
            id = childListBeen.get(2).getId();
            bundle.putInt("cid", id);
            fourFragment.setArguments(bundle);

            fiveFragment = new FiveFragment();
            bundle = new Bundle();
            id = childListBeen.get(3).getId();
            bundle.putInt("cid", id);
            fiveFragment.setArguments(bundle);

            sixFragment = new SixFragment();
            bundle = new Bundle();
            id = childListBeen.get(4).getId();
            bundle.putInt("cid", id);
            sixFragment.setArguments(bundle);

            sevenFragment = new SevenFragment();
            bundle = new Bundle();
            id = childListBeen.get(5).getId();
            bundle.putInt("cid", id);
            sevenFragment.setArguments(bundle);

            eightFragment = new EightFragment();
            bundle = new Bundle();
            id = childListBeen.get(6).getId();
            bundle.putInt("cid", id);
            eightFragment.setArguments(bundle);

            fragmentList.add(oneFragment);
            fragmentList.add(twoFragment);
            fragmentList.add(threeFragment);
            fragmentList.add(fourFragment);
            fragmentList.add(fiveFragment);
            fragmentList.add(sixFragment);
            fragmentList.add(sevenFragment);
            fragmentList.add(eightFragment);
        } else if (count == 3) {          //星座
            oneFragment = new OneFragment();            /////推荐
            bundle = new Bundle();
            bundle.putInt("cid", cid);
            oneFragment.setArguments(bundle);

            twoFragment = new TwoFragment();
            bundle = new Bundle();
            id = childListBeen.get(0).getId();
            bundle.putInt("cid", id);
            twoFragment.setArguments(bundle);

            threeFragment = new ThreeFragment();
            bundle = new Bundle();
            id = childListBeen.get(1).getId();
            bundle.putInt("cid", id);
            threeFragment.setArguments(bundle);

            fragmentList.add(oneFragment);
            fragmentList.add(twoFragment);
            fragmentList.add(threeFragment);
        } else if (count == 7) {          //旅行
            oneFragment = new OneFragment();            /////推荐
            bundle = new Bundle();
            bundle.putInt("cid", cid);
            oneFragment.setArguments(bundle);

            twoFragment = new TwoFragment();
            bundle = new Bundle();
            id = childListBeen.get(0).getId();
            bundle.putInt("cid", id);
            twoFragment.setArguments(bundle);

            threeFragment = new ThreeFragment();
            bundle = new Bundle();
            id = childListBeen.get(1).getId();
            bundle.putInt("cid", id);
            threeFragment.setArguments(bundle);

            fourFragment = new FourFragment();
            bundle = new Bundle();
            id = childListBeen.get(2).getId();
            bundle.putInt("cid", id);
            fourFragment.setArguments(bundle);

            fiveFragment = new FiveFragment();
            bundle = new Bundle();
            id = childListBeen.get(3).getId();
            bundle.putInt("cid", id);
            fiveFragment.setArguments(bundle);

            sixFragment = new SixFragment();
            bundle = new Bundle();
            id = childListBeen.get(4).getId();
            bundle.putInt("cid", id);
            sixFragment.setArguments(bundle);

            sevenFragment = new SevenFragment();
            bundle = new Bundle();
            id = childListBeen.get(5).getId();
            bundle.putInt("cid", id);
            sevenFragment.setArguments(bundle);

            fragmentList.add(oneFragment);
            fragmentList.add(twoFragment);
            fragmentList.add(threeFragment);
            fragmentList.add(fourFragment);
            fragmentList.add(fiveFragment);
            fragmentList.add(sixFragment);
            fragmentList.add(sevenFragment);

        } else if (count == 11) {          //用户推荐
            oneFragment = new OneFragment();            /////推荐
            bundle = new Bundle();
            bundle.putInt("cid", cid);
            oneFragment.setArguments(bundle);

            twoFragment = new TwoFragment();
            bundle = new Bundle();
            id = childListBeen.get(0).getId();
            bundle.putInt("cid", id);
            twoFragment.setArguments(bundle);

            threeFragment = new ThreeFragment();
            bundle = new Bundle();
            id = childListBeen.get(1).getId();
            bundle.putInt("cid", id);
            threeFragment.setArguments(bundle);

            fourFragment = new FourFragment();
            bundle = new Bundle();
            id = childListBeen.get(2).getId();
            bundle.putInt("cid", id);
            fourFragment.setArguments(bundle);

            fiveFragment = new FiveFragment();
            bundle = new Bundle();
            id = childListBeen.get(3).getId();
            bundle.putInt("cid", id);
            fiveFragment.setArguments(bundle);

            sixFragment = new SixFragment();
            bundle = new Bundle();
            id = childListBeen.get(4).getId();
            bundle.putInt("cid", id);
            sixFragment.setArguments(bundle);

            sevenFragment = new SevenFragment();
            bundle = new Bundle();
            id = childListBeen.get(5).getId();
            bundle.putInt("cid", id);
            sevenFragment.setArguments(bundle);

            eightFragment = new EightFragment();
            bundle = new Bundle();
            id = childListBeen.get(6).getId();
            bundle.putInt("cid", id);
            eightFragment.setArguments(bundle);

            nineFragment = new NineFragment();
            bundle = new Bundle();
            id = childListBeen.get(7).getId();
            bundle.putInt("cid", id);
            nineFragment.setArguments(bundle);

            tenFragment = new TenFragment();
            bundle = new Bundle();
            id = childListBeen.get(8).getId();
            bundle.putInt("cid", id);
            tenFragment.setArguments(bundle);

            elevenFragment = new ElevenFragment();
            bundle = new Bundle();
            id = childListBeen.get(9).getId();
            bundle.putInt("cid", id);
            elevenFragment.setArguments(bundle);

            fragmentList.add(oneFragment);
            fragmentList.add(twoFragment);
            fragmentList.add(threeFragment);
            fragmentList.add(fourFragment);
            fragmentList.add(fiveFragment);
            fragmentList.add(sixFragment);
            fragmentList.add(sevenFragment);
            fragmentList.add(eightFragment);
            fragmentList.add(nineFragment);
            fragmentList.add(tenFragment);
            fragmentList.add(elevenFragment);
        }


        //给ViewPager设置适配器
        mPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), fragmentList));
        mPager.setCurrentItem(0);//设置当前显示标签页为第一页
        mPager.setOnPageChangeListener(new MyOnPageChangeListener());//页面变化时的监听器
    }

    public class MyOnPageChangeListener implements ViewPager.OnPageChangeListener {
        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // 取得该控件的实例

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }

        @Override
        public void onPageSelected(int arg0) {
            currIndex = arg0;
            int i = currIndex + 1;
            if (i == 1) {
                initPager1();
            } else if (i == 2) {
                initPager2();
            } else if (i == 3) {
                initPager3();
            } else if (i == 4) {
                initPager4();
            } else if (i == 5) {
                initPager5();
            } else if (i == 6) {
                initPager6();
            } else if (i == 7) {
                initPager7();
            } else if (i == 8) {
                initPager8();
            } else if (i == 9) {
                initPager9();
            } else if (i == 10) {
                initPager10();
            } else if (i == 11) {
                initPager11();
            }
        }
    }

    private void initTextView() {
        view1 = (TextView) findViewById(R.id.tv_guid1);
        view2 = (TextView) findViewById(R.id.tv_guid2);
        view3 = (TextView) findViewById(R.id.tv_guid3);
        view4 = (TextView) findViewById(R.id.tv_guid4);
        view5 = (TextView) findViewById(R.id.tv_guid5);
        view6 = (TextView) findViewById(R.id.tv_guid6);
        view7 = (TextView) findViewById(R.id.tv_guid7);
        view8 = (TextView) findViewById(R.id.tv_guid8);
        view9 = (TextView) findViewById(R.id.tv_guid9);
        view10 = (TextView) findViewById(R.id.tv_guid10);
        view11 = (TextView) findViewById(R.id.tv_guid11);

        view1.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(0);
                initPager1();
            }
        });
        view2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(1);
                initPager2();
            }
        });
        view3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(2);
                initPager3();
            }
        });
        view4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(3);
                initPager4();
            }
        });
        view5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(4);
                initPager5();
            }
        });
        view6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(5);
                initPager6();
            }
        });
        view7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(6);
                initPager7();
            }
        });
        view8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(7);
                initPager8();
            }
        });
        view9.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(8);
                initPager9();
            }
        });
        view10.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(9);
                initPager10();
            }
        });
        view11.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPager.setCurrentItem(10);
                initPager11();
            }
        });
    }

    private void initView() {
        tv_name = (TextView) findViewById(R.id.tv_name);
    }

    public void click_back(View view) {
        finish();
    }

    private void initPager11() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view11.getX() + view11.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view11.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager10() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view10.getX() + view10.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view10.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager9() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view9.getX() + view9.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view9.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager8() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view8.getX() + view8.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view8.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager7() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view7.getX() + view7.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view7.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager6() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view6.getX() + view6.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view6.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
        /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));
    */
    }

    private void initPager5() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view5.getX() + view5.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view5.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
         /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager4() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view4.getX() + view4.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view4.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
        /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager3() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view3.getX() + view3.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view3.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager2() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view2.getX() + view2.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view1.setBackgroundColor(Color.parseColor("#00000000"));
        view2.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /* view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }

    private void initPager1() {
        scrollViewWidth = mHorizontalScrollView.getWidth();
        int rb_px = (int) view1.getX() + view1.getWidth() / 2;
        mHorizontalScrollView.scrollTo(rb_px - scrollViewWidth / 2, 0);
        view1.setBackgroundColor(Color.parseColor("#e4e4e4"));
        view2.setBackgroundColor(Color.parseColor("#00000000"));
        view3.setBackgroundColor(Color.parseColor("#00000000"));
        view4.setBackgroundColor(Color.parseColor("#00000000"));
        view5.setBackgroundColor(Color.parseColor("#00000000"));
        view6.setBackgroundColor(Color.parseColor("#00000000"));
        view7.setBackgroundColor(Color.parseColor("#00000000"));
        view8.setBackgroundColor(Color.parseColor("#00000000"));
        view9.setBackgroundColor(Color.parseColor("#00000000"));
        view10.setBackgroundColor(Color.parseColor("#00000000"));
        view11.setBackgroundColor(Color.parseColor("#00000000"));
       /*  view12.setBackgroundColor(Color.parseColor("#00000000"));
        view13.setBackgroundColor(Color.parseColor("#00000000"));*/
    }
}
